﻿using System;
using Game;
using Game.ui;
using GameFramework.common;
using GameFramework.events;
using GameFramework.timer;
using GameFramework.UI;
using UnityEngine;

public class HomePresenter
{
    private GameObject mainPlayerTextureObj;

    public HomePresenter()
    {
        MVPEventManager.Instance.HomeView_V2P_MainPlayerShow += mainPlayerShow;
        MVPEventManager.Instance.HomeView_V2P_MainPlayerHide += mainPlayerHide;
    }

    public void mainPlayerShow()
    {
        
        
        TimerManager.Instance.schedule(timer =>
        {

            if (mainPlayerTextureObj != null)
            {
                mainPlayerTextureObj.SetActive(true);
                return;
            }
            // Transform gameObject = Transform.find("Other/MainPlayerTexureRender");
            GameObject gameObject = GameObjectUtil.find("Other", "MainPlayerTexureRender");
            if (gameObject != null)
            {
                mainPlayerTextureObj = gameObject;
                gameObject.SetActive(true);
            }
        }, 0, 1);
    } 
    private void mainPlayerHide()
    {
        TimerManager.Instance.schedule(timer =>
        {
            if (mainPlayerTextureObj != null)
            {
                mainPlayerTextureObj.SetActive(false);
            }
        }, 0, 1);
    }
}